/**
 * Created by xu on 2016/1/29.
 */
function afterClickPiggingstructure(){
    getPiggingstructure();
}

function delPiggingstructure(id){
    if (isEmpty(id)){
        alert("删除id不能为空!");
        return;
    }
    if (!confirm("是否确定删除?")){
        return;
    }
    $().invoke(
        p_path+"/pipe/data/piggingstructure/delPiggingstructureRecord.json",
        {"id":id},
        [function(m,r){
            if (r=='success'){
                $("#piggingstructure").refresh();
            }
        },function(m,r){
            alert(r);
        }]
    )
}

function exportPiggingstructure(){
    var data_=$("#piggingstructureQueryForm").serializeFormJSON();
    var p=json2UrlParam(data_);
    backgroundExport(p_path+"/pipe/data/piggingstructure/piggingstructureExport.json?"+p)
    //window.open(p_path+"/pipe/data/piggingstructure/piggingstructureExport.json?"+p);
    //location.href=p_path+"/pipe/data/piggingstructure/piggingstructureExport.json?"+p;
}

function downPiggingstructure(){
    location.href=p_path+"/public/down/downPiggingstructureTemplate.json";
}

//根据条件查询地面标识列表
function queryPiggingstructure(){
    var vR=$("#piggingstructureQueryForm").validationEngine("validate");
    if (!vR){
        return;
    }
    var data_=$("#piggingstructureQueryForm").serializeFormJSON();
    $("#piggingstructure").selectDataAfterSetParm(data_);
}
function getPiggingstructure(){
    var col=[
        {title:"管道名称",name:"lineName",width:"10%",align:"center"},
        {title:"管段名称",name:"segmentName",width:"10%",align:"center"},
        {title:"场站阀室",name:"valveroomName",width:"5%",align:"center"},
        {title:"收发球装置编号",name:"piggingstructureNumber",width:"5%",align:"center"},
        {title:"压力等级",name:"pressureRating",width:"5%",align:"center"},
      //  {title:"生产厂商",name:"manufacturer",width:"5%",align:"center"},
       // {title:"绝对距离(m)",name:"mileage",width:"10%",align:"center",format:function(json){return nvl_(json.mileage)}},
        {title:"详情 删除",name:"",width:"5%",align:"center",format:dataDeatilPiggingstructure}
        /*{title:"删除",name:"",width:"5%",align:"center",format:dataDel}*/
    ];
    $("#piggingstructure").initTable({
        url: p_path + "/pipe/data/piggingstructure/queryPiggingstructureList.json",
        columnData: col,
        doubleRowMode:true,
        isrowClick:true,
        maxHeightMode:false,
        //rowClickMethod:pipeiPiggingstructureRowClick,
        isBindDataToTr:true,
        selectDataNow:true
    });
}

function pipeiPiggingstructureRowClick(data,obj,orderNum){
    try {
        var eventTarget_ = event.target || event.srcElement;
        if (eventTarget_ != null && eventTarget_ != document&& eventTarget_.tagName=="EM"
            && $(eventTarget_).hasClass("xq-icon")) {
            var t=$("#piggingstructure"+orderNum,$("#piggingstructure"));
            $("td",t).html(showpiggingstructureUl(data));
            t.fadeToggle();
            return false;
            /*if ($(eventTarget_).hasClass("delet2")) {
                return;
            }*/
        }
    } catch (e) {
        console.log(e)
    }

}

function dataDeatilPiggingstructure(json){
    var h="<li class=\"w12-4-3-1 no-right\" style='list-style: none;position: relative'>" +
        "<em onclick='opDetail(this,showpiggingstructureUl)' class=\"xq-icon new\"></em>" +
        "<em onclick=delPiggingstructure('"+json.id+"') class=\"delet2 new\"></em></li>";
    return h;
}

function showpiggingstructureUl(json){
    var ulHtml="<div class='info-tr'>";
    ulHtml+=("<div class=\"show-ul \">");
    ulHtml+=("     <ul class=\"show-list\">");
    ulHtml+=("         <li title=>");
    ulHtml+=("             <span class=\"s1\">管道名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.lineName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">管段名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.segmentName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">场站阀室:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.valveroomName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">收发球装置编号:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.piggingstructureNumber)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">行政地域名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.adminRegionName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">压力等级（Mpa）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.pressureRating)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">生产厂商:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.manufacturer)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">生产日期:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.manufacturedDateStr)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">绝对距离(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.mileage)+"</span>");
    ulHtml+=("         </li>");

    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">小球筒长度（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.sbarrelLength)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">小球筒直径（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.sbarrelDiameter)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">小球筒壁厚（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.sbarrelWallThickness)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">大球筒长度（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.bbarrelLength)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">大球筒直径（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.bbarrelDiameter)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">大球筒壁厚（mm）:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.bbarrelWallThickness)+"</span>");
    ulHtml+=("         </li>");


    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">记录人:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.recorder)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">记录时间:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.recordtime)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">统一编号:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.code)+"</span>");
    ulHtml+=("         </li>");

    ulHtml+=("         <li class=\"last-li\" >");
    ulHtml+=("             <span class=\"s1\">备注:</span>");
    ulHtml+=("             <span class=\"s2\"><textarea placeholder=\"备注描述\">"+nvl_(json.createRemark)+"</textarea></span>");
    ulHtml+=("         </li>");
    ulHtml+=("     </ul>");
    ulHtml+=(" </div></div>");
    return ulHtml;
}